package club.emergency.wechat.staff.operate.provider;

import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.redis.spring.RedisLockProvider;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.staff.operate.provider
 * Date: 2018/11/16
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@EnableScheduling
@EnableEurekaClient
@EnableFeignClients
@SpringBootApplication
@MapperScan("club.emergency.wechat.persistence")
@EnableSchedulerLock(defaultLockAtMostFor = "PT30M")
@ComponentScan(basePackages = {
        "club.emergency.wechat.redis",
        "club.emergency.wechat.persistence",
        "club.emergency.wechat.staff.operate.provider"
})
public class StaffOperateProviderService {
    public static void main(String[] args) {
        SpringApplication.run(StaffOperateProviderService.class, args);
    }

    @Bean
    public LockProvider lockProvider(RedisConnectionFactory redisConnectionFactory){
        return new RedisLockProvider(redisConnectionFactory,"ENV");
    }

    @Bean
    public ExecutorService executorService() {
        return Executors.newFixedThreadPool(50);
    }
}
